home *** CD-ROM | disk | FTP | other *** search
/ QuickTime 2.0 Developer Kit / QuickTime 2.0 Developer Kit.iso / mac / MAC / Programming Stuff / Interfaces / CIncludes / WorldScript.h < prev   
Encoding:
C/C++ Source or Header  |  1994-11-11  |  9.9 KB  |  359 lines  |  [TEXT/MPS ]

  1. /*
  2.      File:        WorldScript.h
  3.  
  4.      Copyright:    © 1984-1994 by Apple Computer, Inc.
  5.                  All rights reserved.
  6.  
  7.      Version:    Universal Interfaces 2.0a3  ETO #16, MPW prerelease.  Friday, November 11, 1994. 
  8.  
  9.      Bugs?:        If you find a problem with this file, send the file and version
  10.                  information (from above) and the problem description to:
  11.  
  12.                      Internet:    apple.bugs@applelink.apple.com
  13.                      AppleLink:    APPLE.BUGS
  14.  
  15. */
  16.  
  17. #ifndef __WORLDSCRIPT__
  18. #define __WORLDSCRIPT__
  19.  
  20.  
  21. #ifndef __TYPES__
  22. #include <Types.h>
  23. #endif
  24. /*    #include <ConditionalMacros.h>                                */
  25.  
  26. #ifndef __TRAPS__
  27. #include <Traps.h>
  28. #endif
  29.  
  30. #ifndef __QUICKDRAWTEXT__
  31. #include <QuickdrawText.h>
  32. #endif
  33. /*    #include <MixedMode.h>                                        */
  34.  
  35. #ifdef __cplusplus
  36. extern "C" {
  37. #endif
  38.  
  39. #if GENERATINGPOWERPC
  40. #pragma options align=mac68k
  41. #endif
  42.  
  43. #ifdef __CFM68K__
  44. #pragma lib_export on
  45. #endif
  46.  
  47.  
  48. enum {
  49.     kVariableLengthArray        = 1
  50. };
  51.  
  52. typedef UInt16 WSIOffset;
  53.  
  54. typedef UInt8 WSIByteCount;
  55.  
  56. typedef UInt8 WSIByteIndex;
  57.  
  58. /* offset from start of sub-table to row in state table */
  59. typedef UInt16 WSIStateOffset;
  60.  
  61. typedef UInt32 WSITableOffset;
  62.  
  63. typedef UInt16 WSISubtableOffset;
  64.  
  65. typedef UInt16 WSIGlyphcode;
  66.  
  67. typedef UInt32 WSITableIdentifiers;
  68.  
  69.  
  70. enum {
  71.     kScriptSettingsTag            = 'info',
  72.     kMetamorphosisTag            = 'mort',
  73.     kGlyphExpansionTag            = 'g2g#',
  74.     kPropertiesTag                = 'prop',
  75.     kJustificationTag            = 'kash',
  76.     kCharToGlyphTag                = 'cmap',
  77.     kGlyphToCharTag                = 'pamc',
  78.     kFindScriptRunTag            = 'fstb'
  79. };
  80.  
  81. /****             L O O K U P    T A B L E    T Y P E S        ****/
  82. enum {
  83.     WSILookupSimpleArray        = 0,                            /* a simple array indexed by glyph code */
  84.     WSILookupSegmentSingle        = 2,                            /* segment mapping to single value */
  85.     WSILookupSegmentArray        = 4,                            /* segment mapping to lookup array */
  86.     WSILookupSingleTable        = 6,                            /* sorted list of glyph, value pairs */
  87.     WSILookupTrimmedArray        = 8                                /* a simple trimmed array indexed by glyph code */
  88. };
  89.  
  90. typedef unsigned short WSILookupTableFormat;
  91.  
  92. typedef unsigned short WSILookupValue;
  93.  
  94. /* An offset from the beginning of the lookup table */
  95. typedef unsigned short WSILookupOffset;
  96.  
  97. /*    FORMAT SPECIFIC DEFINITIONS */
  98. /*
  99.         lookupSimpleArray:
  100.         
  101.         This is a simple array which maps all glyphs in the font
  102.         to lookup values.
  103.     */
  104. struct WSILookupArrayHeader {
  105.     WSILookupValue                    lookupValues[1];            /* The array of values indexed by glyph code */
  106. };
  107. typedef struct WSILookupArrayHeader WSILookupArrayHeader;
  108.  
  109. /*
  110.         lookupTrimmedArray:
  111.         
  112.         This is a single trimmed array which maps a single range
  113.         of glyhs in the font to lookup values.
  114.     */
  115. struct WSILookupTrimmedArrayHeader {
  116.     WSIGlyphcode                    firstGlyph;
  117.     WSIGlyphcode                    limitGlyph;
  118.     WSILookupValue                    valueArray[1];
  119. };
  120. typedef struct WSILookupTrimmedArrayHeader WSILookupTrimmedArrayHeader;
  121.  
  122. /* The format specific part of the subtable header */
  123. union WSILookupFormatSpecificHeader {
  124.     WSILookupArrayHeader            lookupArray;
  125.     WSILookupTrimmedArrayHeader        trimmedArray;
  126. };
  127. typedef union WSILookupFormatSpecificHeader WSILookupFormatSpecificHeader;
  128.  
  129. /* The overall subtable header */
  130. struct WSILookupTableHeader {
  131.     WSILookupTableFormat            format;                        /* table format */
  132.     WSILookupFormatSpecificHeader    fsHeader;                    /* format specific header */
  133. };
  134. typedef struct WSILookupTableHeader WSILookupTableHeader;
  135.  
  136. /****        G L Y P H    E X P A N S I O N    ****/
  137.  
  138. enum {
  139. /* fixed 1.0 */
  140.     kCurrentGlyphExpansionVersion = 0x00010000
  141. };
  142.  
  143. typedef unsigned short GlyphExpansionFormats;
  144.  
  145.  
  146. enum {
  147.     GlyphExpansionLookupFormat    = 1,
  148.     GlyphExpansionContextualFormat = 2
  149. };
  150.  
  151. struct ExpandedGlyphCluster {
  152.     WSIByteCount                    numGlyphs;
  153.     WSIByteIndex                    bestGlyph;
  154.     WSIGlyphcode                    glyphs[1];
  155. };
  156. typedef struct ExpandedGlyphCluster ExpandedGlyphCluster;
  157.  
  158. struct ExpandedGlyphOffset {
  159.     WSIGlyphcode                    glyph;
  160.     WSIOffset                        offset;                        /* offset to ExpandedGlyphCluster */
  161. };
  162. typedef struct ExpandedGlyphOffset ExpandedGlyphOffset;
  163.  
  164. struct GlyphExpansionTable {
  165.     Fixed                            version;
  166.     short                            format;
  167.     short                            expansionNumer;
  168.     short                            expansionDenom;                /* num/denom ratio for expansion <2> */
  169.         union {
  170.                 struct GlyphExpansionStateTable {
  171.                     WSISubtableOffset                stateTableOffset;
  172.                     WSISubtableOffset                classTableOffset;
  173.                     WSISubtableOffset                actionTableOffset; /* state, class and actions tables follow here... */
  174.                 }                            stateTable;
  175.             WSILookupTableHeader            lookup;                /* expanded glyph clusters follow here... */
  176.         }                            table;
  177. };
  178. typedef struct GlyphExpansionTable GlyphExpansionTable;
  179.  
  180. /* Glyph-to-Character constants and types  */
  181.  
  182. enum {
  183.     kCurrentGlyphToCharVersion    = (Fixed)0x00010100
  184. };
  185.  
  186. typedef unsigned short GlyphToCharLookupFormats;
  187.  
  188.  
  189. enum {
  190.     kGlyphToCharLookup8Format    = 1,
  191.     kGlyphToCharLookup16Format    = 2,
  192.     kGlyphToCharLookup32Format    = 3
  193. };
  194.  
  195. typedef UInt8 GlyphToCharFontIndex;
  196.  
  197. typedef UInt8 QDGlyphcode;
  198.  
  199. struct GlyphToCharActionTable {
  200.     WSISubtableOffset                fontNameOffset;                /* offset relative to this table */
  201.     WSILookupTableHeader            actions;                    /* only support lookupSimpleArray format for now */
  202. };
  203. typedef struct GlyphToCharActionTable GlyphToCharActionTable;
  204.  
  205. struct GlyphToCharActionHeader {
  206.     short                            numTables;                    /* 0..n */
  207.     WSISubtableOffset                offsets[1];                    /* offsets from start of action table header */
  208. };
  209. typedef struct GlyphToCharActionHeader GlyphToCharActionHeader;
  210.  
  211. struct GlyphToCharHeader {
  212.     Fixed                            version;
  213.     WSISubtableOffset                actionOffset;                /* offset to GlyphToCharActionHeader */
  214.     short                            format;                        /* size of font mask */
  215.     WSILookupTableHeader            mappingTable;
  216. };
  217. typedef struct GlyphToCharHeader GlyphToCharHeader;
  218.  
  219. /* JUSTIFICATION TYPES
  220.     WorldScript supports justification of text using insertion. The justification
  221.     table specifies a insertion string to insert between 2 specified glyphs.
  222.     Each combination of inter-glyph boundary can be assigned a justification priority,
  223.     the higher the priority the more justification strings inserted at that position.
  224.     
  225.     The priorities for each inter-glyph boundary are specified by the justification table's
  226.     state table.
  227.     
  228.     Special handling is done for scripts which use spaces to justify, because the width of 
  229.     a space varies depending on the setting of SpaceExtra. This is why the number of spaces
  230.     per inserting string is specified in the justification table.
  231.  
  232. */
  233.  
  234. enum {
  235. /* 1.0 not supported */
  236.     kCurrentJustificationVersion = 0x0200
  237. };
  238.  
  239. enum {
  240.     kJustificationStateTableFormat = 1
  241. };
  242.  
  243. enum {
  244. /* WSI's internal limitation <12> */
  245.     kMaxJustificationStringLength = 13
  246. };
  247.  
  248. typedef UInt8 WSIJustificationPriority;
  249.  
  250.  
  251. enum {
  252.     WSIJustificationSetMarkMask    = 0x80
  253. };
  254.  
  255. struct WSIJustificationStateEntry {
  256.     WSIJustificationPriority        markPriority;                /* non-zero priorities means insertion */
  257.     WSIJustificationPriority        priority;
  258.     WSIStateOffset                    newState;
  259. };
  260. typedef struct WSIJustificationStateEntry WSIJustificationStateEntry;
  261.  
  262. typedef unsigned short WSIJustificationClasses;
  263.  
  264.  
  265. enum {
  266.     wsiJustEndOfLineClass        = 0,
  267.     wsiJustEndOfRunClass        = 1,
  268.     wsiJustDeletedGlyphClass    = 2,
  269.     wsiJustUserDefinedClass        = 3
  270. };
  271.  
  272. typedef unsigned short WSIJustificationStates;
  273.  
  274.  
  275. enum {
  276.     wsiStartOfLineState            = 0,                            /* pre-defined states */
  277.     wsiStartOfRunState            = 1,
  278.     wsiUserDefinedState            = 2
  279. };
  280.  
  281. /* pre-multiplied: class# * sizeof(WSIJustificationStateEntry) */
  282. typedef UInt8 WSIJustificationClassOffset;
  283.  
  284. struct WSIJustificationStateTable {
  285.     short                            maxPriorities;
  286.     unsigned short                    rowWidth;                    /* width of a state table row in bytes */
  287.     short                            classTableOffset;
  288.     short                            stateTableOffset;
  289. };
  290. typedef struct WSIJustificationStateTable WSIJustificationStateTable;
  291.  
  292. struct WSIJustificationHeader {
  293.     short                            version;
  294.     short                            format;
  295.     Point                            scaling;                    /* numer/denom scaling of priority weights <7> */
  296.     unsigned short                    spacesPerInsertion;            /* # of $20 chars in justification insertion string <12> */
  297.     unsigned short                    justStringOffset;            /* offset to justification string */
  298.     WSIJustificationStateTable        stateTable;                    /* long-aligned boundary aligned w/ spacesPerInsertion field - justification string follows */
  299. };
  300. typedef struct WSIJustificationHeader WSIJustificationHeader;
  301.  
  302. /* Line Layout's Property table version <11> */
  303.  
  304. enum {
  305. /* v1.0 */
  306.     currentPropsTableVersion    = 0x00010000
  307. };
  308.  
  309. enum {
  310. /* ??? is this right */
  311.     kCharToGlyphCurrentVersion    = 0100
  312. };
  313.  
  314. /* pass as priorityWeight to JustifyWSILayout to use script's current just setting */
  315. enum {
  316.     kScriptsDefaultJustWeight    = -1
  317. };
  318.  
  319. struct WSIGlyphInfoRec {
  320.     UInt8                            qdChar;
  321.     SInt8                            rightToLeft;                /* !0 means rightToLeft, 0 means leftToRight */
  322.     short                            fontID;
  323.     short                            originalOffset;                /* or negative original offset if not in original text input */
  324.     unsigned short                    unused;                        /* long-align */
  325. };
  326. typedef struct WSIGlyphInfoRec WSIGlyphInfoRec, **WSIGlyphInfoHandle;
  327.  
  328. typedef Handle WSILayoutHandle;
  329.  
  330. extern pascal WSILayoutHandle NewWSILayout(WSILayoutHandle layoutH, Ptr text, short txLength, short lineDirection, unsigned long flags, OSErr *err)
  331.  FOURWORDINLINE(0x2F3C, 0X8414, 0x0040, 0xA8B5);
  332. extern pascal WSILayoutHandle JustifyWSILayout(WSILayoutHandle layoutH, Fixed slop, short priorityWeight, JustStyleCode styleRunPosition, Point numer, Point denom, OSErr *err)
  333.  FOURWORDINLINE(0x2F3C, 0x8418, 0x0042, 0xA8B5);
  334. extern pascal Fixed MeasureWSILayout(WSILayoutHandle layoutH, Point numer, Point denom)
  335.  FOURWORDINLINE(0x2F3C, 0x840C, 0x0044, 0xA8B5);
  336. extern pascal void DrawWSILayout(WSILayoutHandle layoutH, Point numer, Point denom)
  337.  FOURWORDINLINE(0x2F3C, 0x800C, 0x0046, 0xA8B5);
  338. /* "low-level" routines */
  339. extern pascal WSIGlyphInfoHandle GetWSILayoutParts(WSILayoutHandle layoutH, WSIGlyphInfoHandle destH, short *numGlyphs, OSErr *err)
  340.  FOURWORDINLINE(0x2F3C, 0x8410, 0x0048, 0xA8B5);
  341. extern pascal void DrawWSIGlyphs(short length, Ptr qdCodes, Point numer, Point denom)
  342.  FOURWORDINLINE(0x2F3C, 0x800E, 0x004A, 0xA8B5);
  343. extern pascal Fixed xMeasureWSIGlyphs(Ptr *qdCodes, short length, Point numer, Point denom)
  344.  FOURWORDINLINE(0x2F3C, 0x840E, 0x004C, 0xA8B5);
  345.  
  346. #ifdef __CFM68K__
  347. #pragma lib_export off
  348. #endif
  349.  
  350. #if GENERATINGPOWERPC
  351. #pragma options align=reset
  352. #endif
  353.  
  354. #ifdef __cplusplus
  355. }
  356. #endif
  357.  
  358. #endif /* __WORLDSCRIPT__ */
  359.